<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>测试文件上传</h1>
<!--上传文件必须设置编码类型-->
<form action="" enctype="multipart/form-data">
    <input type="text" name="title" placeholder="图片标题">
    <input type="file" name="picFile">
    <input type="button" value="开始上传" @click="upload()">
</form>
<!--引入Vue-->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<!--引入Axios-->
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
    let vm = new Vue({
        el:"form",
        data:{},
        methods:{
            upload:function () {
                let data = new FormData(document.querySelector("form"));
                axios.post("/upload",data).then(function () {
                    alert("上传完成!");
                })

            }
        }
    })
</script>
</body>
</html>